package com.platform.data.handle.converter.impl;

import com.platform.data.common.CommonConstant;
import com.platform.data.handle.converter.AbstractDataTypeProcessHandler;
import com.platform.data.handle.converter.DataTypeEnum;

import java.util.Objects;
import java.util.regex.Matcher;

/**
 * 枚举值[字符串]
 *
 * @author zhuweijun
 * @version 1.0.0
 * @since 2025/5/13 16:53
 */
public class EnumStringTypeProcessHandler extends AbstractDataTypeProcessHandler {


    /**
     * 枚举值[字符串]
     *
     * @param typeEnum typeEnum
     * @param fieldName fieldName
     * @param fieldValue fieldValue
     * @return {@link Object}
     */
    @Override
    public Object process(DataTypeEnum typeEnum, String fieldName, String fieldValue) {
        // 内容匹配冒号（中英文）
        Matcher matcher = super.matcherValue(colonPattern, fieldValue);
        if(Objects.nonNull(matcher)){
            return matcher.group(CommonConstant.ONE).trim();
        }
        return fieldValue;
    }
}
